# 二分查找
def binarySerach(searchValue):
    left = 0
    right = len(arr)-1
    found = False
    while found == False and left<=right:
        middle = (left+right)//2  # 5/2 2.5  5//2 2
        if arr[middle] == searchValue:
            found = True
        else:
            if arr[middle]>searchValue:
                right = middle-1
            else:
                left = middle+1
    if found == True:
        return middle
    else:
        return -1

if __name__ == '__main__':
    arr = [2,3,4,5,6,7,8]
    print(binarySerach(3))
